/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Extra;

/**
 *
 * @author nisarg
 */
public class radix {
    //static String input[] = {"abcdefgh","abcdefg","abcdef","abcde","abcd","abc","ab","az"};
    //static String input[] = {"nisarg","nisara","nisarb","nis","nai"};
    static String input[] = {"abcdefgh","abcdefg","abcdef","abcde","abcd","abcz","ab","bat", "basd", "ba", "bas","abcdefgh","abcdefg","abcdef","abcde","abcd","abcz","ab","bat", "basd", "ba", "bas"};
    //static String input[] = {"abcdefgh","abcdefg","abcdef","abcde","abcd","abcz","ab","a"};
    static int max = input[0].length();
    static int[] alpha = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    public static void main(String args[]) {
        findMax();
        int[] all = {0,0};
        int k =0;
        int size = input.length;
        //for(int count = 0;count<max;count++) {
            for(int i=0;i<size;i++) {
                for(int j=0;j<size;j++) {
                    //if(count < input[i].length() && count < input[j].length() && /*input[i].length() < input[j].length() &&*/ input[i].charAt(count) < input[j].charAt(count)) {
                    //    swap(i,j);
                    //}
                    if(input[i].compareTo(input[j]) < 0) {
                        swap(i,j);
                    }
                            
                    /*else if(input[i].length() < count) {
                        
                        if(i<j) {
                           if(input[i].charAt(count-1)   < input[j].charAt(count-1)) {
                               
                           }
                        }
                    }*/
                }
            }
        //}
        //set();
        for(int i=0;i<size;i++) {
            System.out.println("" + input[i]);
        }
        
    }
    static void findMax() {
        int size = input.length;
        for(int i=0;i<size;i++) {
            if(max < input[i].length()) {
                max = input[i].length();
            }
        }
    }
    static void swap(int i,int j) {
        String temp = "";
        temp = input[i];
        input[i] = input[j];
        input[j] = temp;
    }   
    /*static void set() {
        int k = 0;
        
        for(int i = 0;i<input.length;i++) {
            if(input[i].length() < max) {
                k = max;
                while(k<max) {
                    input[i].charAt(k++) = null;
                }
            }
        }
    }*/
    static void set() {
        int size = input.length;
        for(int i=0;i<size;i++) {
            for(int j=0;j<size;j++) {
                if(i < j && input[i].contains(input[j]) && input[i].charAt(0) == input[j].charAt(0)) {
                    //System.out.println(input[i] + " with " + input[j]);
                    swap(i,j);
                }
            }
        }
    }
}